import { getS210motorList, getV90motorList } from '@/services/sales/salesNeedInfo';
import {
  PageContainer,
  ProCardTabsProps,
  ProFormInstance,
  ProFormMoney,
} from '@ant-design/pro-components';
import {
  ModalForm,
  ProCard,
  ProFormDependency,
  ProFormDigit,
  ProFormGroup,
  ProFormSelect,
  ProFormText,
  ProForm,
} from '@ant-design/pro-components';
import { Card, InputNumber, Select, Space } from 'antd';
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
import type { FormDialogProps } from './data';
import type { FormLayout } from 'antd/es/form/Form';
import access from '@/access';
import { useAccess, useLocation } from 'umi';
import { SettingFilled } from '@ant-design/icons';
const { Option } = Select;

const rowNullData = {
  motorId: null, //电机ID
  ratedCurrent: null, //额定电流(A)
  ratedTorque: null, //额定扭矩(Nm)
  ratedPower: null, //额定功率(KW)
  ecoderType: null, //编码器
  brake: null, //抱闸
  ratedSpeed: null, //额定速度(rpm)
  ratedVoltage: null, //额定电压(V)
  motorInertia: null, //电机惯量(10^-4kg·cm2)
};
const LAYOUT_TYPE_HORIZONTAL = 'horizontal';
const CalcEdit: React.FC<FormDialogProps> = (props, uploadRef) => {
  const [visible, setVisible] = useState(false);
  const formRef = useRef<ProFormInstance>();
  const [disabled, setDisabled] = useState(false);
  const [confirmLoading, setConfirmLoading] = useState(false);
  const [initialValues, setInitialValues] = useState({});
  const [controlMode, setControlMode] = useState(0);

  const [formLayoutType, setFormLayoutType] = useState<FormLayout>(LAYOUT_TYPE_HORIZONTAL);
  const [grid, setGrid] = useState(true);
  const access = useAccess();
  const [tab, setTab] = useState('');
  const [tabPosition, setTabPosition] = useState<ProCardTabsProps['tabPosition']>('top');
  const location = useLocation();
  const [vmaxEposLu, setVmaxEposLu] = useState(0);

  useEffect(() => {
    setVisible(props.visible);
    setDisabled(props.disabled);
    setInitialValues(props.initialValues || {});
    setVmaxEposLu(6 * props.initialValues.vmaxEpos * props.initialValues.positionAccuracy);
    if (props.initialValues.controlMode === 2) {
      setTab('tab1');
    } else if (props.initialValues.controlMode === 3) {
      setTab('tab2');
    } else {
      setTab('tab3');
    }
  }, [props.visible, props.disabled, props.initialValues]);

  useEffect(() => {
    if (location.query.id !== undefined && location.query.id !== null) {
      formRef.current?.setFieldsValue(props.values);
    }
  }, [props.values]);

  useImperativeHandle(uploadRef, () => {
    // return返回的值就可以被父组件获取到,没返回的值就获取不到
    return {
      // 获取其中的值
      getFieldsValue: () => {
        return formRef.current?.getFieldsValue();
      },
      // 设置值
      setFieldsValue: (value: object) => {
        // console.log(formRef.current);
        // debugger;
        return formRef.current?.setFieldsValue({ shaftName: '测试', hardwareIdentifier: 'hhh' });
      },
      // 重置其中的值
      resetFields: () => {
        return formRef.current?.resetFields();
      },
    };
  });

  return (
    <div>
      <ModalForm
        title={props.title}
        visible={visible}
        formRef={formRef}
        initialValues={initialValues}
        onFinish={async () => {
          setConfirmLoading(true);
          await props.onOk();
          setConfirmLoading(false);
          return true;
        }}
        onValuesChange={(changeValues) => {
          if (changeValues.controlMode != null && changeValues != undefined) {
            if (changeValues.controlMode === 2) {
              setTab('tab1');
            } else if (changeValues.controlMode === 3) {
              setTab('tab2');
            } else {
              setTab('tab3');
            }
          }
          if (changeValues.motorTime != null && changeValues.motorTime != undefined) {
            const rSpeed = formRef.current?.getFieldValue('ratedSpeed');
            const Im = formRef.current?.getFieldValue('motorInertia');
            const rTorque = formRef.current?.getFieldValue('ratedTorque');
            let rSpeedSecTemp = rSpeed / 60.0;
            let angularVelTemp = 2 * Math.PI * rSpeedSecTemp;
            let angularAccTemp = (1000 * angularVelTemp) / changeValues.motorTime;
            let accMomentTemp = Im * angularAccTemp;
            let momentRatioTemp = accMomentTemp / rTorque;
            formRef.current?.setFieldsValue({
              ratedSecSpeed: rSpeedSecTemp.toFixed(4),
              angularVel: angularVelTemp.toFixed(4),
              angularAcc: angularAccTemp.toFixed(4),
              accMoment: accMomentTemp.toFixed(4),
              momentRatio: momentRatioTemp.toFixed(2),
            });
          }
          // if (changeValues.vmaxEpos != null && changeValues.vmaxEpos != undefined &&
          //   changeValues.positionAccuracy != null && changeValues.positionAccuracy != undefined) {
          if (changeValues.vmaxEpos != null && changeValues.vmaxEpos != undefined) {
            // if (changeValues.positionAccuracy != null && changeValues.positionAccuracy != undefined) {
            const vmEpos = formRef.current?.getFieldValue('vmaxEpos');
            const mmLU = formRef.current?.getFieldValue('positionAccuracy');
            let vmEposLu = 6 * vmEpos * mmLU;
            console.log(vmEposLu, '---vmEposLu---');
            formRef.current?.setFieldsValue({
              vmaxEposTran: vmEposLu,
            });
            // setVmaxEposLu(vmEposLu);
            // }
          }
          if (changeValues.positionAccuracy != null && changeValues.positionAccuracy != undefined) {
            const vmEpos = formRef.current?.getFieldValue('vmaxEpos');
            const mmLU = formRef.current?.getFieldValue('positionAccuracy');
            let vmEposLu = 6 * vmEpos * mmLU;
            console.log(vmEposLu, '---vmEposLu---');
            formRef.current?.setFieldsValue({
              vmaxEposTran: vmEposLu,
            });
            // setVmaxEposLu(vmEposLu);
          }
        }}
        modalProps={{
          destroyOnClose: true,
          bodyStyle: { height: 500, overflowY: 'scroll' },
          onCancel: () => props.onCancel(),
        }}
        layout={formLayoutType}
        grid={grid}
        rowProps={{
          gutter: [16, formLayoutType === 'inline' ? 16 : 0],
        }}
      >
        <ProFormGroup key="lib1" title="基础信息配置" titleStyle={{ backgroundColor: '#f0f0f0' }}>
          <ProFormText hidden={true} name="id" label="轴信息Id" />
          <ProFormText
            width="md"
            name="shaftName"
            label="轴名称"
            colProps={{ md: 12, xl: 8 }}
            rules={[{ required: true, message: '请输入轴名称信息' }]}
          />
          <ProFormSelect
            width="md"
            name="driveType"
            label="驱动类型"
            options={[
              { label: 'V90', value: 1 },
              { label: 'S210', value: 2 },
            ]}
            colProps={{ md: 12, xl: 8 }}
            fieldProps={{
              onChange: (val, val2) => {
                formRef.current?.setFieldsValue({ motorOrderNum: null, ...rowNullData });
              },
            }}
            rules={[{ required: true, message: '此项是必填项目' }]}
          />
          <ProFormDigit
            width="md"
            colProps={{ md: 12, xl: 8 }}
            key="hardwareIdentifier"
            name="hardwareIdentifier"
            label="硬件标识符"
          />
        </ProFormGroup>

        <ProFormGroup
          key="lib2"
          title="电机配置数据"
          titleStyle={{ backgroundColor: '#f0f0f0' }}
          collapsible
        >
          <ProFormDependency name={['driveType']}>
            {({ driveType }) => {
              if (driveType == 1) {
                return (
                  <ProFormSelect
                    showSearch
                    width="md"
                    name="motorOrderNum"
                    label="V90电机订货号"
                    placeholder={'请输入前5个连续字符进行检索'}
                    colProps={{ md: 12, xl: 16 }}
                    debounceTime={1000}
                    request={async (params) => {
                      const result = await getV90motorList({ blurry: params.keyWords });
                      result.data.push({ motorOrderNum: '第三方', id: '第三方' });
                      return result.data.map((item) => {
                        return {
                          key: item.id,
                          label: item.motorOrderNum,
                          value: item.motorOrderNum,
                          rowData: item,
                        };
                      });
                    }}
                    fieldProps={{
                      onChange: (val, child) => {
                        delete child.rowData.id;
                        formRef.current?.setFieldsValue({
                          ...rowNullData,
                          ...child.rowData,
                        });
                      },
                    }}
                  />
                );
              } else {
                return (
                  <ProFormSelect
                    showSearch
                    width="md"
                    name="motorOrderNum"
                    label="S210电机订货号"
                    placeholder={'请输入前5个连续字符进行检索'}
                    colProps={{ md: 12, xl: 16 }}
                    debounceTime={1000}
                    request={async (params) => {
                      const result = await getS210motorList({ blurry: params.keyWords });
                      result.data.push({ motorOrderNum: '第三方', id: '第三方' });
                      return result.data.map((item) => {
                        return {
                          key: item.id,
                          label: item.motorOrderNum,
                          value: item.motorOrderNum,
                          rowData: item,
                        };
                      });
                    }}
                    fieldProps={{
                      onChange: (val, child) => {
                        delete child.rowData.id;
                        formRef.current?.setFieldsValue({
                          ...rowNullData,
                          ...child.rowData,
                        });
                      },
                    }}
                  />
                );
              }
            }}
          </ProFormDependency>
          <ProFormDependency name={['motorOrderNum']}>
            {({ motorOrderNum }) => {
              if (motorOrderNum == '第三方') {
                return [
                  <ProFormDigit
                    colProps={{ md: 12, xl: 8 }}
                    width="md"
                    key="motorId"
                    name="motorId"
                    label="电机ID"
                  />,
                  <ProFormSelect
                    width="md"
                    name="ecoderType"
                    colProps={{ md: 12, xl: 8 }}
                    label="编码器类型"
                    key="ecoderType"
                    options={[
                      { label: '单圈绝对编码器', value: 0 },
                      { label: '多圈绝对编码器', value: 1 },
                      { label: '增量式编码器', value: 2 },
                    ]}
                  />,
                  <ProFormSelect
                    width="md"
                    colProps={{ md: 12, xl: 8 }}
                    name="brake"
                    key="brake"
                    label="抱闸配置 P1215"
                    options={[
                      { label: '不带抱闸', value: 0 },
                      { label: '带抱闸', value: 1 },
                    ]}
                  />,
                  <ProFormDigit
                    colProps={{ md: 12, xl: 8 }}
                    width="md"
                    key="ratedVoltage"
                    name="ratedVoltage"
                    label="额定电压 P304 [V]"
                  />,
                  <ProFormDigit
                    width="md"
                    colProps={{ md: 12, xl: 8 }}
                    name="ratedCurrent"
                    key="ratedCurrent"
                    label="额定电流 P305 [A]"
                  />,
                  <ProFormDigit
                    width="md"
                    colProps={{ md: 12, xl: 8 }}
                    key="ratedPower"
                    name="ratedPower"
                    label="额定功率 P307 [kW]"
                  />,
                  <ProFormDigit
                    colProps={{ md: 12, xl: 8 }}
                    width="md"
                    key="ratedSpeed"
                    name="ratedSpeed"
                    label="额定速度 P311 [rpm]"
                  />,
                  <ProFormDigit
                    width="md"
                    colProps={{ md: 12, xl: 8 }}
                    key="ratedTorque"
                    name="ratedTorque"
                    label="额定转矩 P312 [Nm]"
                  />,
                  <ProFormDigit
                    colProps={{ md: 12, xl: 12 }}
                    width="md"
                    key="motorInertia"
                    name="motorInertia"
                    label="电机转动惯量 P341 [kg.m2]"
                  />,
                ];
              } else {
                return [
                  <ProFormDigit
                    colProps={{ md: 12, xl: 8 }}
                    width="md"
                    key="motorId"
                    name="motorId"
                    disabled={true}
                    label="电机ID"
                  />,
                  <ProFormSelect
                    width="md"
                    name="ecoderType"
                    colProps={{ md: 12, xl: 8 }}
                    label="编码器类型"
                    key="ecoderType"
                    disabled={true}
                    options={[
                      { label: '单圈绝对编码器', value: 0 },
                      { label: '多圈绝对编码器', value: 1 },
                      { label: '增量式编码器', value: 2 },
                    ]}
                  />,
                  <ProFormSelect
                    width="md"
                    colProps={{ md: 12, xl: 8 }}
                    name="brake"
                    key="brake"
                    label="抱闸配置 P1215"
                    disabled={true}
                    options={[
                      { label: '不带抱闸', value: 0 },
                      { label: '带抱闸', value: 1 },
                    ]}
                  />,
                  <ProFormDigit
                    colProps={{ md: 12, xl: 8 }}
                    width="md"
                    key="ratedVoltage"
                    name="ratedVoltage"
                    disabled={true}
                    label="额定电压 P304 [V]"
                  />,
                  <ProFormDigit
                    width="md"
                    colProps={{ md: 12, xl: 8 }}
                    name="ratedCurrent"
                    key="ratedCurrent"
                    disabled={true}
                    label="额定电流 P305 [A]"
                  />,
                  <ProFormDigit
                    width="md"
                    colProps={{ md: 12, xl: 8 }}
                    key="ratedPower"
                    disabled={true}
                    name="ratedPower"
                    label="额定功率 P307 [kW]"
                  />,
                  <ProFormDigit
                    colProps={{ md: 12, xl: 8 }}
                    width="md"
                    key="ratedSpeed"
                    name="ratedSpeed"
                    disabled={true}
                    label="额定速度 P311 [rpm]"
                  />,
                  <ProFormDigit
                    width="md"
                    colProps={{ md: 12, xl: 8 }}
                    key="ratedTorque"
                    disabled={true}
                    name="ratedTorque"
                    label="额定转矩 P312 [Nm]"
                  />,
                  <ProFormDigit
                    colProps={{ md: 12, xl: 10 }}
                    width="md"
                    key="motorInertia"
                    name="motorInertia"
                    disabled={true}
                    label="电机转动惯量 P341 [kg.m2]"
                  />,
                ];
              }
            }}
          </ProFormDependency>
          <ProFormDigit
            colProps={{ md: 12, xl: 8 }}
            width="md"
            key="tbrakeOpen"
            name="tbrakeOpen"
            label="抱闸打开时间 P1216 [ms]"
          />
          <ProFormDigit
            colProps={{ md: 12, xl: 8 }}
            width="md"
            key="tbrakeClose"
            name="tbrakeClose"
            label="抱闸闭合时间 P1217 [ms]"
          />
        </ProFormGroup>

        <ProFormGroup
          key="lib4"
          title="驱动配置"
          titleStyle={{ backgroundColor: '#f0f0f0' }}
          collapsible
        >
          <ProFormSelect
            width="md"
            name="loadType"
            colProps={{ md: 12, xl: 8 }}
            label="负载类型"
            options={[
              { label: '水平', value: 1 },
              { label: '旋转', value: 2 },
              { label: '垂直', value: 3 },
              // { label: '斜坡', value: 4 },
              { label: '其它', value: 5 },
            ]}
          />
          <ProFormSelect
            width="md"
            name="mechanicalStructure"
            label="机械结构"
            colProps={{ md: 12, xl: 8 }}
            options={[
              { label: '丝杠', value: 1 },
              // { label: '齿轮齿条', value: 2 },
              { label: '皮带轮', value: 3 },
              { label: '圆盘', value: 4 },
              // { label: '辊式带', value: 5 },
              // { label: '链条', value: 6 },
              { label: '其它', value: 7 },
            ]}
          />
          <ProFormSelect
            width="md"
            name="commTelegram"
            label="控制报文 P922"
            colProps={{ md: 12, xl: 8 }}
            options={[
              { label: '105', value: 105 },
              { label: '111', value: 111 },
              { label: '102', value: 102 },
              { label: '3', value: 3 },
              { label: '1', value: 1 },
            ]}
          />
          <ProFormSelect
            width="md"
            name="additionalTelegram"
            label="附加报文 P8864"
            colProps={{ md: 12, xl: 8 }}
            options={[
              { label: 'None', value: 999 },
              { label: '750', value: 750 },
            ]}
          />
          <ProFormSelect
            width="md"
            name="controlMode"
            label="控制模式"
            colProps={{ md: 12, xl: 8 }}
            options={[
              { label: 'TO', value: 1 },
              { label: 'Epos', value: 2 },
              { label: 'Speed', value: 3 },
            ]}
          />
          <ProFormSelect
            width="md"
            name="motorRotation"
            label="电机旋转方向"
            colProps={{ md: 12, xl: 8 }}
            options={[
              { label: '正向', value: 0 },
              { label: '反向', value: 1 },
            ]}
          />
          <ProFormDigit
            width="md"
            colProps={{ md: 12, xl: 10 }}
            name="velocityMax"
            label="电机最大转速 P1082 [rpm]"
          />
          <ProFormDigit
            width="md"
            colProps={{ md: 12, xl: 10 }}
            name="refSpeed"
            label="参考转速 P2000 [rpm]"
          />
          <ProFormDigit
            width="md"
            colProps={{ md: 12, xl: 10 }}
            name="refCurrent"
            label="参考电流 P2002 [Arms]"
          />
          <ProFormDigit
            width="md"
            colProps={{ md: 12, xl: 10 }}
            name="refTorque"
            label="参考转矩 P2003 [Nm]"
          />
          <ProFormGroup key="lib4-1" title="数字输入">
            <ProFormSelect
              width="md"
              name="di1Epos"
              label="DI1 P29301"
              colProps={{ md: 12, xl: 8 }}
              options={[
                { label: 'NA', value: 0 },
                { label: 'RESET', value: 2 },
                { label: 'CWL', value: 3 },
                { label: 'CCWL', value: 4 },
                { label: 'TLIM', value: 11 },
                { label: 'SLIM', value: 20 },
                { label: 'REF', value: 24 },
                { label: 'EMGS', value: 29 },
              ]}
            />
            <ProFormSelect
              width="md"
              name="di2Epos"
              label="DI2 P29302"
              colProps={{ md: 12, xl: 8 }}
              options={[
                { label: 'NA', value: 0 },
                { label: 'RESET', value: 2 },
                { label: 'CWL', value: 3 },
                { label: 'CCWL', value: 4 },
                { label: 'TLIM', value: 11 },
                { label: 'SLIM', value: 20 },
                { label: 'REF', value: 24 },
                { label: 'EMGS', value: 29 },
              ]}
            />
            <ProFormSelect
              width="md"
              name="di3Epos"
              label="DI3 P29303"
              colProps={{ md: 12, xl: 8 }}
              options={[
                { label: 'NA', value: 0 },
                { label: 'RESET', value: 2 },
                { label: 'CWL', value: 3 },
                { label: 'CCWL', value: 4 },
                { label: 'TLIM', value: 11 },
                { label: 'SLIM', value: 20 },
                { label: 'REF', value: 24 },
                { label: 'EMGS', value: 29 },
              ]}
            />
            <ProFormSelect
              width="md"
              name="di4Epos"
              label="DI4 P29304"
              colProps={{ md: 12, xl: 8 }}
              options={[
                { label: 'NA', value: 0 },
                { label: 'RESET', value: 2 },
                { label: 'CWL', value: 3 },
                { label: 'CCWL', value: 4 },
                { label: 'TLIM', value: 11 },
                { label: 'SLIM', value: 20 },
                { label: 'REF', value: 24 },
                { label: 'EMGS', value: 29 },
              ]}
            />
          </ProFormGroup>
          <ProFormGroup key="lib4-2" title="数字输出">
            <ProFormSelect
              width="md"
              name="do1Epos"
              label="DO1 P29330"
              colProps={{ md: 12, xl: 8 }}
              options={[
                { label: 'RDY', value: 1 },
                { label: 'FAULT', value: 2 },
                { label: 'INP', value: 3 },
                { label: 'ZSP', value: 4 },
                { label: 'TLR', value: 6 },
                { label: 'MBR', value: 8 },
                { label: 'OLL', value: 9 },
                { label: 'REFOK', value: 12 },
                { label: 'RDY_ON', value: 14 },
                { label: 'STO', value: 15 },
                { label: 'PZD1', value: 16 },
                { label: 'PZD2', value: 17 },
              ]}
            />
            <ProFormSelect
              width="md"
              name="do2Epos"
              label="DO2 P29331"
              colProps={{ md: 12, xl: 8 }}
              options={[
                { label: 'RDY', value: 1 },
                { label: 'FAULT', value: 2 },
                { label: 'INP', value: 3 },
                { label: 'ZSP', value: 4 },
                { label: 'TLR', value: 6 },
                { label: 'MBR', value: 8 },
                { label: 'OLL', value: 9 },
                { label: 'REFOK', value: 12 },
                { label: 'RDY_ON', value: 14 },
                { label: 'STO', value: 15 },
                { label: 'PZD1', value: 16 },
                { label: 'PZD2', value: 17 },
              ]}
            />
          </ProFormGroup>
          <ProFormGroup key="lib4-3" title="转矩限幅值">
            <ProFormDigit
              width="md"
              colProps={{ md: 12, xl: 10 }}
              name="torqueLimUpper"
              label="转矩限幅上限 P29050[0] [%]"
            />
            <ProFormDigit
              width="md"
              colProps={{ md: 12, xl: 10 }}
              name="torqueLimLower"
              label="转矩限幅下限 P29051[0] [%]"
              min={-100000}
            />
          </ProFormGroup>
        </ProFormGroup>

        <ProFormGroup
          key="lib5"
          title="工艺参数"
          titleStyle={{ backgroundColor: '#f0f0f0' }}
          collapsible
        >
          <ProFormDigit
            width="md"
            colProps={{ md: 12, xl: 8 }}
            name="dynamicCoeff"
            label="动态系数"
          />
          <ProCard
            layout="center"
            tabs={{
              type: 'card',
              tabPosition,
              activeKey: tab,
              items: [
                {
                  label: 'EPOS',
                  key: 'tab1',
                  disabled: tab != 'tab1',
                  children: [
                    <ProFormGroup key="lib5-1" style={{ marginTop: '10px' }}>
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="gearRationLoad"
                        label="负载转速 (EPOS) P29248 [rpm]"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="gearRationMotor"
                        label="电机转速 (EPOS) P29249 [rpm]"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="positionAccuracy"
                        label="10mm对应的LU (EPOS)"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="luLoopEpos"
                        label="每转LU (EPOS) P29247"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="kprEpos"
                        label="位置环增益 (EPOS) P29110 [1000/min]"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="posFilterEpos"
                        label="位置环滤波 (EPOS) P2533 [1000/min]"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="coeffVelEpos"
                        label="速度前馈系数 (EPOS) P29111 [%]"
                      />
                      <ProFormGroup>
                        <ProFormDigit
                          width="md"
                          colProps={{ md: 12, xl: 12 }}
                          name="vmaxEpos"
                          label="EPOS 最大速度 P2571 [m/s]"
                          fieldProps={{
                            onChange: (val) => {},
                          }}
                          // fieldProps={{ precision: 5}}
                          // extra={vmaxEposLu + "[1000LU/min]"}
                        />
                        <ProFormDigit
                          width="md"
                          style={{
                            color: 'red',
                            width: '200px',
                            border: '1px solid',
                            borderColor: 'red',
                          }}
                          fieldProps={{
                            style: {
                              color: 'red',
                            },
                          }}
                          colProps={{ md: 10, xl: 10 }}
                          name="vmaxEposTran"
                          key="vmaxEposTran"
                          disabled
                          addonBefore="即"
                          addonAfter="[1000LU/min]"
                      />
                      </ProFormGroup>
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="accmaxEpos"
                        label="EPOS 最大加速度 P2572 [1000 LU/s²]"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="dccmaxEpos"
                        label="EPOS 最大减速度 P2573 [1000 LU/s²]"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="jerkEpos"
                        label="EPOS 急动限制 P2574 [1000 LU/s³]"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="jerkActiveEpos"
                        label="EPOS 急动限制激活 P2575"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="torquePreCtrl"
                        label="推力前馈LR质量/推力前馈质量 (EPOS) P2567"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 13 }}
                        name="refApproachVel"
                        label="回零参考点逼近速度 (EPOS) P2605 [1000LU/min]"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 13 }}
                        name="refSearchVel"
                        label="回零参考点搜索速度 (EPOS) P2608 [1000LU/min]"
                      />
                      <ProFormSelect
                        width="md"
                        name="modualActiveEpos"
                        label="模态轴激活 (EPOS) P29245"
                        colProps={{ md: 12, xl: 12 }}
                        options={[
                          { label: 'No', value: 0 },
                          { label: 'Yes', value: 1 },
                        ]}
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="modualLengthEpos"
                        label="模数补偿范围 (EPOS) P29246 [LU]"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="jog1VelEpos"
                        label="JOG1速度 (EPOS) P2585 [1000 LU/min]"
                        min={-1000000}
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="jog2VelEpos"
                        label="JOG2速度 (EPOS) P2586 [1000 LU/min]"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="softLimitPositive"
                        label="正软限位开关 (EPOS) p2580 [LU]"
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="softLimitNegative"
                        label="负软限位开关 (EPOS) p2581 [LU]"
                        min={-1000000000}
                      />
                      <ProFormDigit
                        width="md"
                        colProps={{ md: 12, xl: 12 }}
                        name="refCoordinate"
                        label="绝对编码器校正位置 (EPOS) P2599 [LU]"
                        min={-10000}
                      />
                      <ProFormSelect
                        width="md"
                        name="pzdSend"
                        label="自定义PZD发送字 (EPOS) P29151"
                        colProps={{ md: 12, xl: 12 }}
                        options={[
                          { label: '无功能', value: 0 },
                          { label: '实际扭矩', value: 1 },
                          { label: '实际绝对电流', value: 2 },
                          { label: 'DI状态', value: 3 },
                        ]}
                      />
                    </ProFormGroup>
                  ],
                },
                {
                  label: 'Speed',
                  key: 'tab2',
                  disabled: tab != 'tab2',
                  children: [
                    <div>
                      <br></br>
                      <ProFormGroup key="lib5-2">
                        <ProFormDigit
                          width="md"
                          colProps={{ md: 12, xl: 20 }}
                          name="kpSpeed"
                          label="速度环增益Kp (Speed) V90 P29120 [Nms/rad] /S210 P1460"
                        />
                        <ProFormDigit
                          width="md"
                          colProps={{ md: 12, xl: 20 }}
                          name="tnSpeed"
                          label="速度环积分时间Tn (Speed) V90 P29121 [ms] / S210 P1462"
                        />
                        <ProFormDigit
                          width="md"
                          colProps={{ md: 12, xl: 12 }}
                          name="tincSpeed"
                          label="斜坡上升时间 (Speed) P1120 [s]"
                        />
                        <ProFormDigit
                          width="md"
                          colProps={{ md: 12, xl: 12 }}
                          name="tdecSpeed"
                          label="斜坡下降时间 (Speed) P1121 [s]"
                        />
                        <ProFormDigit
                          width="md"
                          colProps={{ md: 12, xl: 12 }}
                          name="tstartSpeed"
                          label="斜坡圆弧起始时间 (Speed) P1130 [s]"
                        />
                        <ProFormDigit
                          width="md"
                          colProps={{ md: 12, xl: 12 }}
                          name="tstopSpeed"
                          label="斜坡圆弧结束时间 (Speed) P1131 [s]"
                        />
                        <ProFormDigit
                          width="md"
                          colProps={{ md: 12, xl: 12 }}
                          name="off3TdecSpeed"
                          label="OFF3斜坡下降时间 (Speed) P1135 [s]"
                        />
                        <ProFormDigit
                          width="md"
                          colProps={{ md: 12, xl: 12 }}
                          name="tmonitorSpeed"
                          label="静态检测的监控时间 (Speed) P1227 [s]"
                        />
                      </ProFormGroup>
                    </div>,
                  ],
                },
                {
                  label: 'TO',
                  key: 'tab3',
                  disabled: tab != 'tab3',
                  children: [
                    <div>
                      <br></br>
                      <br></br>
                    </div>,
                  ],
                },
              ],
              onChange: (key) => {
                setTab(key);
              },
            }}
          />
        </ProFormGroup>
      </ModalForm>
    </div>
  );
};
const DriveParaCalcEdit = forwardRef<unknown, FormDialogProps>(CalcEdit);

export default DriveParaCalcEdit;
